﻿using System;
using MaLu.Common;
using MaLu.Data;
using System.Data;

namespace MaluJg.web.PovertyIn
{
    public partial class PDetail : PPage
    {
        
        protected int RecordID
        {
            get
            {
                int gd = 0;
                if (Request["ID"] != null)
                {
                    int.TryParse(Request["ID"] ?? "0", out gd);

                }
                else
                {
                    if (ViewState["ID"] != null)
                        gd = (int)ViewState["ID"];


                }
                if (ViewState["ID"] == null)
                    ViewState["ID"] = gd;
                return gd;
            }
            set
            {
                ViewState["ID"] = value;
            }

        }
         protected string SType = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "扶贫帮困详细清单";
            this.UseTabber = true;
            SType = Request["type"] ?? "fbooth";
            if (!IsPostBack)
            {
               BindData();
            }
        }
        private void BindData()
        {
            uvLive1.Visible = false;
            uVSick1.Visible = false;
            uVDeformity1.Visible = false;
            uVStudy1.Visible = false;
            uVOther1.Visible = false;
         
            switch (SType)
            {
                case "sliving":
                    uvLive1.Visible = true;
                    uvLive1.LoadData(); break;
                case "sdeformity":
                    uVDeformity1.Visible = true;
                    uVDeformity1.LoadData(); break;
                case "ssick":
                    uVSick1.Visible = true;
                    uVSick1.LoadData(); break;
                case "sstudy":
                    uVStudy1.Visible = true;
                    uVStudy1.LoadData(); break;

                case "sothers":
                    uVOther1.Visible = true;
                    uVOther1.LoadData(); break;
              
                default: break;

            }


        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {


            string table = "sliving";
            if (SType == "sliving")
            {
                table = "sliving";
            }
            if (SType == "sdeformity")
            {
                table = "sdeformity";
            }
            if (SType == "ssick")
            {
                table = "ssick";
            }
            if (SType == "sstudy")
            {
                table = "sstudy";
            }
            if (SType == "sothers")
            {
                table = "sothers";
            }
            string sql = string.Format("delete from [{0}] where id ='{1}'",table, RecordID);
            SqlHelper.Instance.ExecuteNonQuery(Provider, sql);
            ClientScript.RegisterStartupScript(this.GetType(), "Delete", "<script>parent.location.href = parent.location.href</script>");
        }

    }
}
